package com.fitness.servlet;

import com.fitness.dao.PerformanceDAO;
import com.fitness.entity.Performance;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;

@WebServlet("/PerformanceServlet")
public class PerformanceServlet extends HttpServlet {

    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        // 查询年度绩效数据
        PerformanceDAO performanceDAO = new PerformanceDAO();
        List<Performance> performanceList = performanceDAO.getManagerAnnualPerformance();

        // 传递数据到 JSP
        request.setAttribute("performanceList", performanceList);
        // 转发到绩效列表页面
        request.getRequestDispatcher("/WEB-INF/views/admin/performanceList.jsp").forward(request, response);
    }

    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        doGet(request, response);
    }
}